package com.xxgc.eow.service.impl;

import com.xxgc.eow.entity.Noticecollect;
import com.xxgc.eow.mapper.NoticecollectMapper;
import com.xxgc.eow.service.INoticecollectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 通知收藏表 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-05-30
 */
@Service
public class NoticecollectServiceImpl extends ServiceImpl<NoticecollectMapper, Noticecollect> implements INoticecollectService {

    @Resource
    private NoticecollectMapper noticecollectMapper;

    @Override
    public List<Noticecollect> selectByNotifiedId(int notifiedId) {
        return  noticecollectMapper.selectByNotifiedId(notifiedId);
    }

    @Override
    public int delNoticeCollect(int noticeCollectId) {
        Date date = new Date();
        Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
        return noticecollectMapper.delNoticeCollect(localDateTime,noticeCollectId);
    }

    @Override
    public List<Noticecollect> selectAll() {
        return noticecollectMapper.selectAll();
    }
}
